﻿<phone:PhoneApplicationPage 
    x:Class="TestAutoComplete.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:localControls="clr-namespace:TestAutoComplete.Converters"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True">
    
    <phone:PhoneApplicationPage.Resources>
       
            <localControls:VisibilityConverter x:Key="Vis" />
       
    </phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">

            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="72" />
                    <RowDefinition />
                </Grid.RowDefinitions>

                <!-- Row 0 is a 'placeholder' for the AutoCompleteBox control -->

                <!-- The AutoCompleteBox experience -->
                <!-- Must be the last XAML in the Grid to ensure a top z-order -->
                <!-- It must span the entire grid, starting with row 0. -->
                <!-- Warning: the design surface does not like this template unfortunately -->
                <!-- AutoCompleteBox must be vertically aligned with the placeholder -->
                <Grid Grid.RowSpan="2" Width="456">
                <Image Source="Images/pbyg.png" VerticalAlignment="Bottom" HorizontalAlignment="Right" Stretch="None" />
                


                    <toolkit:AutoCompleteBox   ValueMemberBinding="{Binding description}" MinimumPopulateDelay="200"
                                     ValueMemberPath="description" x:Name="_autoCompleteBox" Populating="LocSearchPopulating"
                                   VerticalAlignment="Top" Width="420" HorizontalAlignment="Left"  KeyUp="AutoCompleteBoxKeyUp"  SelectionChanged="AutoCompleteBoxSelectionChanged">
                        <toolkit:AutoCompleteBox.ItemTemplate>
                            <DataTemplate>


                                <TextBlock Margin="8,7" toolkit:TiltEffect.IsTiltEnabled="True" Text="{Binding description}" Foreground="Black" TextWrapping="NoWrap"
                               Style="{StaticResource PhoneTextNormalStyle}" />






                            </DataTemplate>
                        </toolkit:AutoCompleteBox.ItemTemplate>
                        <toolkit:AutoCompleteBox.Template>
                            <ControlTemplate TargetType="toolkit:AutoCompleteBox">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition />
                                    </Grid.RowDefinitions>
                                    <TextBox x:Name="Text" Background="{TemplateBinding Background}"
                             BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
                             FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStyle="{TemplateBinding FontStyle}"
                             FontWeight="{TemplateBinding FontWeight}" Foreground="Black" InputScope="{TemplateBinding InputScope}"
                             Opacity="{TemplateBinding Opacity}" Padding="{TemplateBinding Padding}" Style="{TemplateBinding Style}" />
                                    <ListBox Margin="0"
                             Visibility="{Binding Path=IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource Vis}}"
                             Grid.Row="1" x:Name="Selector" Background="White" FontFamily="{TemplateBinding FontFamily}"
                             FontSize="{TemplateBinding FontSize}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}"
                             Foreground="{TemplateBinding Foreground}" IsTabStop="False" ItemContainerStyle="{TemplateBinding ItemContainerStyle}"
                             ItemTemplate="{TemplateBinding ItemTemplate}" Opacity="{TemplateBinding Opacity}"
                             BorderBrush="{StaticResource PhoneTextBoxEditBorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
                             Padding="0,0" MaxHeight="185"  >
                                        <ListBox.Template>

                                            <ControlTemplate>

                                                <Border CornerRadius="10" BorderBrush="White" BorderThickness="5">

                                                    <ScrollViewer Padding="{TemplateBinding Padding}"
                                          Background="{TemplateBinding Background}" BorderThickness="0" TabNavigation="{TemplateBinding TabNavigation}">

                                                        <StackPanel>

                                                            <ItemsPresenter />

                                                        </StackPanel>

                                                    </ScrollViewer>

                                                </Border>

                                            </ControlTemplate>

                                        </ListBox.Template>
                                    </ListBox>
                                </Grid>
                            </ControlTemplate>
                        </toolkit:AutoCompleteBox.Template>
                    </toolkit:AutoCompleteBox>
                </Grid>
            </Grid>
        </Grid>
    </Grid>

    <!--Sample code showing usage of ApplicationBar-->
    <!--<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="MenuItem 1"/>
                <shell:ApplicationBarMenuItem Text="MenuItem 2"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>-->

</phone:PhoneApplicationPage>